home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 43
/
Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso
/
Aminet
/
comm
/
tcp
/
Amster-main.lha
/
Amster_Install
/
Rexx
/
AmsterReport_Triton.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
2000-09-08
|
8KB
|
261 lines
/*
** Scans the Amster.shares file and gives a report on the statistics of your library.
** $VER: AmsterReport.rexx 0.3 (08.9.2000)
**
** By Roger Clark (kaedric@texas.net)
** September 8, 2000
**
** This script requires the rexxreqtools.library which can be found on Aminet.
**
** util/rexx/RexxReqTools.lha
**
** This script requires the tritonrexx.library which can be found on Aminet.
** util/rexx/TritonRexx376.lha
**
** This script requires the triton.library which can be found on Aminet.
** dev/gui/tri20b1usr.lha
**
*/
Options Results
Parse Arg ShareList
Signal On Break_C
Signal On failure
Signal On halt
Signal On ioerr
Signal On syntax
If ~Show('L','tritonrexx.library') Then Do
If ~addlib('tritonrexx.library',10,-30,0) Then Do
Say 'Could not access the tritonrexx.library!'
Exit 10
End
End
If ~Show('L','rexxreqtools.library') Then Do
If ~addlib('rexxreqtools.library',10,-30,0) Then Do
Say 'Could not access the rexxreqtools.library!'
Exit 10
End
End
NumSongs = 0
NumBytes = 0
NumBytesSent = 0
SBytes = 0
UBytes = 0
NumReq = 0
NumSecs = 0
TopSongs. = ""
TopSongs.0 = 0
TopReq = 0
SFlag = "KB"
UFlag = "KB"
Playtime = "0:00:00"
Dir = ""
DefaultFile = "Amster.shares"
windowtags = WindowID(1),
WindowTitle('Amster Report'),
BeginMenu('Project'),
MenuItem('N_New Report',7),
MenuItem('?_About',8),
MenuItem('Q_Quit',9),
'HorizGroupAC',
'VertGroupA',
'Space',
'BeginLine',
Text3(' Shared Songs '),
'Space',
ClippedTextBoxMW(Right(Copies(' ',12)||NumSongs,12),1,12),
'Space',
'EndLine',
'Space',
'BeginLine',
Text3(' Shared Bytes '),
'Space',
ClippedTextBoxMW(Right(Copies(' ',12)||SBytes||' '||SFlag,12),2,12),
'Space',
'EndLine',
'Space',
'BeginLine',
Text3(' Uploaded Songs '),
'Space',
ClippedTextBoxMW(Right(Copies(' ',12)||NumReq,12),3,12),
'Space',
'EndLine',
'Space',
'BeginLine',
Text3(' Uploaded Bytes '),
'Space',
ClippedTextBoxMW(Right(Copies(' ',12)||UBytes||' '||UFlag,12),4,12),
'Space',
'EndLine',
'Space',
'BeginLine',
Text3(' Library Playtime '),
'Space',
ClippedTextBoxMW(Right(Copies(' ',12)||Playtime,12),5,12),
'Space',
'EndLine',
'Space',
'EndGroup',
'Space',
'VertSeparator',
'Space',
'VertGroupAC',
NamedSeparator('Top Requested Songs'),
ListRO('TopSongs',6,0),
'EndGroup',
'EndGroup',
'EndProject'
app = TR_CREATEAPP('TRCA_Name AmsterReport')
If app ~= '00000000'x Then Do
window = TR_OPENPROJECT(app,windowtags)
If window ~= '00000000'x Then Do
Call ScanFile
Done = 0
Do While Done ~= 1
Call TR_WAIT(app,'')
Do While TR_HANDLEMSG(app,'event')
If event.trm_class = 'TRMS_ACTION' Then Do
Select
When event.trm_id = 7 Then Do
ShareList = ""
Call ScanFile
End
When event.trm_id = 8 Then Do
Call rtezrequest("AmsterReport.rexx v0.3"||D2C(10)||"By: Roger Clark (kaedric@texas.net)"||D2C(10)||"Date: September 8, 2000","Thanks","About AmsterReport.rexx")
End
When event.trm_id = 9 Then Do
Done = 1
End
Otherwise NOP
End
End
If event.trm_class = 'TRMS_CLOSEWINDOW' Then Do
Done = 1
End
End
End
Call TR_CLOSEPROJECT(window)
End
Call TR_DELETEAPP(app)
End
Exit
ScanFile:
NumSongs = 0
NumBytes = 0
NumBytesSent = 0
SBytes = 0
UBytes = 0
NumReq = 0
NumSecs = 0
TopSongs. = ""
TopSongs.0 = 0
TopReq = 0
SFlag = "KB"
UFlag = "KB"
Playtime = "0:00:00"
If ShareList = "" then Do
If Dir = "" then Dir = Pragma("D")
ShareList = rtfilerequest(Dir,DefaultFile,"Choose Share File",,,)
If ShareList = "" then Return
End
If LastPos('/',ShareList) > LastPos(':',ShareList) then Do
DefaultFile = SubStr(ShareList,LastPos('/',ShareList)+1)
Dir = Left(ShareList,LastPos('/',ShareList))
End
Else Do
DefaultFile = SubStr(ShareList,LastPos(':',ShareList)+1)
Dir = Left(ShareList,LastPos(':',ShareList))
End
If Exists(ShareList) then Do
Call TR_SETATTRIBUTE(window,6,'TROB_Listview',TopSongs)
Call Open(In,ShareList,'R')
Do Until EOF(In)
SongName = ""
MD5 = ""
Size = 0
Bitrate = ""
Frequency = ""
Play = 0
ReqCountFlag = ""
Requests = 0
Data = ReadLn(In)
If Length(Data) < 1 then Leave
Parse Var Data '"'SongName'"' MD5 Size Bitrate Frequency Play ReqCountFlag Requests
If Requests = "" then Requests = 0
NumSongs = NumSongs + 1
NumReq = NumReq + Requests
If Requests = TopReq then Do
TopSongs.0 = TopSongs.0 + 1
Y = TopSongs.0
TopSongs.Y = SongName
End
If Requests > TopReq then Do
TopReq = Requests
TopSongs. = ""
TopSongs.0 = 1
TopSongs.1 = SongName
End
If Requests > 0 then Do
NumBytesSent = NumBytesSent + (Size * Requests)
If NumBytesSent > (1024 * 1024 * 1024) Then Do
UFlag = "GB"
UBytes = NumBytesSent / 1024 / 1024 / 1024 * 100 % 1 / 100
End
Else If NumBytesSent > (1024 * 1024) Then Do
UFlag = "MB"
UBytes = NumBytesSent / 1024 / 1024 * 100 % 1 / 100
End
Else Do
UFlag = "KB"
UBytes = NumBytesSent / 1024 * 100 % 1 / 100
End
End
NumBytes = NumBytes + Size
If NumBytes > (1024 * 1024 * 1024) Then Do
SFlag = "GB"
SBytes = NumBytes / 1024 / 1024 / 1024 * 100 % 1 / 100
End
Else If NumBytes > (1024 * 1024) Then Do
SFlag = "MB"
SBytes = NumBytes / 1024 / 1024 * 100 % 1 / 100
End
Else Do
SFlag = "KB"
SBytes = NumBytes / 1024 * 100 % 1 / 100
End
NumSecs = NumSecs + Play
Hours = NumSecs % 3600
Minutes = (NumSecs % 60) - (Hours * 60)
Seconds = NumSecs - (Hours * 3600) - (Minutes * 60)
Playtime = Hours":"Right("00"||Minutes,2)":"Right("00"||Seconds,2)
Call TR_SETATTRIBUTE(window,1,'TRAT_TEXT',Right(Copies(' ',12)||NumSongs,12))
Call TR_SETATTRIBUTE(window,2,'TRAT_TEXT',Right(Copies(' ',12)||SBytes||' '||SFlag,12))
Call TR_SETATTRIBUTE(window,3,'TRAT_TEXT',Right(Copies(' ',12)||NumReq,12))
Call TR_SETATTRIBUTE(window,4,'TRAT_TEXT',Right(Copies(' ',12)||UBytes||' '||UFlag,12))
Call TR_SETATTRIBUTE(window,5,'TRAT_TEXT',Right(Copies(' ',12)||Playtime,12))
End
If TopReq > 0 Then Do
Call TR_SETATTRIBUTE(window,6,'TROB_Listview',TopSongs)
End
Call Close(In)
End
Return
break_c:
failure:
halt:
ioerr:
syntax:
Call rtezrequest('Notify the author about this!'||D2C(10)||'+++ Error' rc 'in line' sigl '-' ERRORTEXT(rc),'Oops!','Error!')
If app ~= '00000000'x THEN
Call TR_DELETEAPP(app)
Exit